package com.future.orm.session;

import java.sql.SQLException;
import java.util.List;

/**
 *
 * @author shiyong
 * 2020/5/20 10:22
 */
public interface SqlSession {
    /**
     * 查询返回多条记录
     *
     * @param statementId SQL语句ID
     * @param param 查询参数
     * @return java.util.List<E>
     * @author shiyong
     * 2020/5/26 15:07
    */
    <E> List<E> selectList(String statementId, Object... param) throws Exception;

    /**
     * 查询返回单条记录
     *
     * @param statementId SQL语句ID
     * @param param 查询参数
     * @return T
     * @author shiyong
     * 2020/5/26 15:08
    */
    <T> T selectOne(String statementId, Object... param) throws Exception;

    /**
     * 插入记录
     *
     * @param statementId SQL语句ID
     * @param param 插入数据
     * @return int
     * @author shiyong
     * 2020/6/12 8:10
    */
    int insert(String statementId, Object... param) throws Exception;

    /**
     * 更新记录
     *
     * @param statementId SQL语句ID
     * @param param 更新数据
     * @return int
     * @author shiyong
     * 2020/6/12 8:10
    */
    int update(String statementId, Object... param) throws Exception;

    /**
     * 删除记录
     *
     * @param statementId SQL语句ID
     * @param param 删除参数
     * @return int
     * @author shiyong
     * 2020/6/12 8:13
    */
    int delete(String statementId, Object... param) throws Exception;

    /**
     * 提交结果
     *
     * @author shiyong
     * 2020/6/12 8:14
    */
    void commit() throws SQLException;

    /**
     * 回退
     *
     * @author shiyong
     * 2020/6/12 8:14
    */
    void rollback() throws SQLException;

    /**
     * 关闭数据库连接
     *
     * @author shiyong
     * 2020/6/14 13:43
    */
    void close() throws SQLException;

    /**
     * 获取Mapper接口代理类
     *
     * @param mapperClass Mapper接口
     * @return T
     * @author shiyong
     * 2020/6/14 14:06
    */
    public <T> T getMapper(Class<?> mapperClass);
}
